<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>派车管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../../static/css/font.css">
    <link rel="stylesheet" href="../../static/css/xadmin.css">
    <script type="text/javascript" src="../../static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../../static/js/jquery.min.js"></script>

</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input id="id" name="id" type="hidden">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>审核状态</label>
                <div class="layui-input-inline">
                    <button id="noPass" name="noPass" class="layui-btn layui-btn-danger" value="1">审核未通过</button>
                </div>
                <div class="layui-input-inline">
                    <button id="pass" name="pass" class="layui-btn layui-btn layui-btn-normal" value="2">审核已通过</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    var url = window.location.href;

    var id;
    layui.use('form', function() {
        var form = layui.from;
      //  var status;

        id= URL_Request('id');
        console.log("id==",id);
        /* form.render(); */
        //检查项目添加到下拉框中
        $.ajax({
            url : "/paiche/findid/"+id,
            type : "GET",
            dataType : "json",
            success : function(data) {
                console.log("加载", data);
                var u = data;
                console.log(u);
                $("#id").val(data.data[0].t_paiche_id);
               // $("#status").val(data.data[0].status);
            }
        })
    });

    //正则获取url中的参数
    function URL_Request(strName) {
        var strHref = document.location.toString();
        var intPos = strHref.indexOf("?");
        var strRight = strHref.substr(intPos + 1); //==========获取到右边的参数部分
        var arrTmp = strRight.split("&"); //=============以&分割成数组

        for (var i = 0; i < arrTmp.length; i++) //===========循环数组
        {
            var dIntPos = arrTmp[i].indexOf("=");
            var paraName = arrTmp[i].substr(0, dIntPos);
            var paraData = arrTmp[i].substr(dIntPos + 1);
            if (paraName.toUpperCase() == strName.toUpperCase()) {
                return paraData;
            }
        }
        return "";
    }

    // 审核  按钮
    $(function () {
        $('#noPass').click(function () {
            var status = '1';
            var id = $('#id').val();
            console.log('status=====',status,"====id====",id);
            //console.log("审核未通过" + pass);
            $.ajax({
                url : "/paiche/updatePaicheStatus/"+id+"/"+status,
                type : "POST",
                dataType : "json",
                data:{
                    //'id':id,
                    //'status' : status
                },
                success : function(data) {
                    alert(data);
                }
            })
            var index = parent.layer
                .getFrameIndex(window.name), p = parent;

            //然后下面先关闭子窗口
            parent.layer.close(index);

            //再刷新
            p.location.reload();
        });

        // 审核通过
        $("#pass").click(function () {
            var status = '2';
            var id = $("#id").val();
            console.log('paicheid====='+status+"====id===="+id);
            //console.log("审核未通过" + pass);
            $.ajax({
                url : "/paiche/updatePaicheStatus/"+id+"/"+status,
                type : "POST",
                dataType : "json",
                data:{
                    // 'id':id,
                    // 'status' : status
                },
                success : function(data) {

                }
            })
            var index = parent.layer
                .getFrameIndex(window.name), p = parent;

            //然后下面先关闭子窗口
            parent.layer.close(index);

            //再刷新
            p.location.reload();
        });
    })

</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>